const http = require('http');
const querystring = require('querystring');
const url = require('url');

const sleep = () => {
  return new Promise((resolve, reject)=>{
    setTimeout(() => {
      resolve();
    }, 5000);
  })
};

http.createServer(async (req, res) => {
  console.log(`${req.headers["user-agent"]}: ${new Date().toLocaleString()} --- 进入`);
  await sleep();
  console.log(`${req.headers["user-agent"]}: ${new Date().toLocaleString()} --- 结束`);
  res.end(`${new Date().toLocaleString()}`);
}).listen(3000,()=>{
  console.log('server is running at 3000')
});

